﻿

using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;

namespace Domain
{
  public  class DataContext : DbContext
    {
        public DataContext(DbContextOptions<DataContext> options) : base(options)
        {

        }

        public DbSet<Department> Departments { get; set; }
        public DbSet<Menu> Menus { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<User> Users { get; set; }
        public DbSet<UserRole> UserRoles { get; set; }
        public DbSet<RoleMenu> RoleMenus { get; set; }
        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.Entity<UserRole>().HasKey(ur => new { ur.UserId, ur.RoleId });
            builder.Entity<RoleMenu>().HasKey(rm => new { rm.RoleId, rm.MenuId });
            builder.Entity<UserMenu>().HasKey(um => new { um.UserId, um.MenuId });
            //builder.Entity<User>().HasData(
            //    new User
            //    {
            //        UserName = "111",
            //        Password = "123456",
            //        Name = "张三",
            //        EMail = "1908106320@qq.com",
            //        MobileNumber = "1111111",
            //        Remarks = "dsdsd",

            //        CreateTime =Convert.ToDateTime("2012-1-1"),
            //    }
            //    );

            base.OnModelCreating(builder);
        }
    }
}
